package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.resource.MessageConstant;
import com.itheima.service.SetMealService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetMealMobilWebController {

    @Reference
    private SetMealService setMealService;

    /**
     * 获取所有套餐数据
     * @param
     * @return
     */
    @RequestMapping("/findAllSetmeal.do")
    public Result findAllSetMeal(){
        try {
            List<Setmeal> setmealList=setMealService.findAllSetMealMobilWeb();
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmealList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true,MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }

    /**
     * 获取手机端套餐详情，包含对应的检查组以及检查组对应的检查项
     * @param id
     * @return
     */
    @RequestMapping("/findSetMealDetail.do")
    public Result findSetMailDetail(@RequestParam("id") Integer id){
        try {
            Setmeal setmeal=setMealService.findSetMailDetail(id);
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true,MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }
}
